<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<input id="username" type="text"><br><br>
<div></div>
<script>
	document.querySelector("input").onblur=function () {
		var username = document.getElementById("username").value;
		var xhr = new XMLHttpRequest();
		xhr.open("get","./api/checkUser.php?username="+username)
	    xhr.send(null);
		xhr.onreadystatechange=function () {
		  if(xhr.readyState===4 && xhr.status===200){
		  	var data = xhr.responseText;
		  	document.querySelector("div").innerHTML=data;
		  }
		}
	}
</script>
</body>
</html>